package com.wantupai.mvp.framework.lce.impl.activity;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.ViewGroup;

import com.wantupai.mvp.mvp.MvpPresenter;
import com.wantupai.mvp.mvp.MvpView;
import com.wantupai.mvp.mvp.lce.activity.MvpActivity;


/**
 * @param <D>
 * @param <V>
 * @param <P>
 * @author zhangqing
 */

public abstract class BaseMvpActivity<D, V extends MvpView<D>, P extends MvpPresenter<V>> extends MvpActivity<D, V, P>
{

    private static final String TAG = "BaseMvpActivity";


    private boolean isInit = false;
    private Context mContext;

    protected final Context getContext()
    {
        return mContext;
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(getContentView());
        mContext = this;
        ViewGroup mViewGroup = (ViewGroup) findViewById(android.R.id.content);
        initContentView(getWindow().getDecorView());
        initNavigation((ViewGroup) mViewGroup.getChildAt(0));
    }


    @Override
    protected void onResume()
    {
        super.onResume();
        if (!isInit)
        {
            initData();
            isInit = true;
        }
    }

    public abstract int getContentView();

    public void initNavigation(ViewGroup viewGroup)
    {

    }

    public void initContentView(View view)
    {

    }


    public void initData()
    {
        loadData(false);
    }

}
